<?php
class App_Module_Admin_Component_Media_Tpl_BlockList extends App_Module_Admin_Tpl_List
{
	protected $_showCells = array('thumb', 'title', 'icons');
	protected $_emptyListMessage = 'FILES_NOT_FOUND';

    public function GetList($ctrlName, $filter, $baseUrlParams, $page, $params)
    {
        $onPage = Mozg_Cfg::Get('admin/media')->GetPerPage();

        $paginator = new Mozg_Paginator($page, $onPage);
        $pattern = Mozg::Router('http')->Create(array_merge($baseUrlParams, array('media_page' => '__page__')));

        $this->ctrlName = $ctrlName;
        $this->baseUrlParams = $baseUrlParams;
        $this->params = $params;

        $objects = Mozg_Mapper::Get('Media')->GetList($filter, $paginator);
        $paginator->SetTotalCount(Mozg_Mapper::Get('Media')->GetTotalRows());
        $this->content = $this->CreateList($objects, $paginator, $pattern);

        return $this->render('media/_block_list.phtml');
    }

	protected function GetCellThumb($obj)
	{
		$this->thumbFolder = Mozg_Mapper::Get('Image')->GetImageThumbFolder('mediathumbnail');
		$this->obj = $obj;
		return $this->render('media/blocklist/_thumb.phtml');
	}

	protected function GetCellTitle($obj)
	{
		$this->obj = $obj;
		return $this->render('media/list/_title.phtml');
	}

	protected function GetCellIcons($obj)
	{
		$icons = array();
		if ($this->params['contentButton'])
		{
			$icons['right'] = array(
	        					'title' => 'ADD_TO_CONTENT',
	        					'url' =>'#',
								'attr' => array('data-id' => $obj->GetId())
	        					);
		}

		return $this->GetTpl('Icon')->GetIconSet($icons, 'list');
	}
}